﻿@model IList<Inovout.Kuajing.Models.ShipmentOrder>
@{
    Layout = "~/Views/Shared/_Layout.cshtml"; 
}
@section styles {

    <style>
        .form form {
            margin: 20em auto;
        }

        div.error {
            padding-left: 2px;
            padding-bottom: 2px;
            font-weight: bold;
            color: #EA5200;
        }
    </style>
}

@section scriptsHead {
    <script>
        $(document).ready(function () {

            $("#tb_contact > tbody").find("a").on("click", function () {
                $("#orderNo").val($(this).parents("tr").find("td").eq(0).text());
                $("#orderId").val($(this).parents("tr").find("td").eq(0).children("input").val());
                $("#logisticsOrderNo").val($(this).parents("tr").find("td").eq(7).children("input").val());
                $("#logisticsCompanyName").val($(this).parents("tr").find("td").eq(4).text());
                $("#shipper").modal('show');
            })

            $("#orderform").validate({
                rules: {
                    logisticsOrderNo: {
                        required: true,
                        minlength: 3
                    },
                    logisticsCompanyName: {
                        required: true,
                        minlength: 3
                    }
                },
                messages: {
                    logisticsOrderNo: {
                        required: "请输入订单号",
                        minlength: "最小长度不小于3"
                    },
                    logisticsCompanyName: {
                        required: "请输入运输公司名称",
                        minlength: "最小长度不小于3"
                    }
                },
                errorElement: "div"
            })


            $("#save").on("click", function () {
                $("#orderform").submit();
                //$("#shipper").modal('hide');
            })

        })
    </script>

}

<div>
    <table class="table table-bordered" id="tb_contact">
        <thead>
            <tr>
                <td class="col-md-1">订单编号</td>
                <td class="col-md-2">收货人姓名</td>
                <td class="col-md-2">收货人地址</td>
                <td class="col-md-1">收货人手机</td>
                <td class="col-md-1">物流公司</td>
                <td class="col-md-1">状态</td>
                <td class="col-md-1">商品总价</td>
                <td class="col-md-1">操作</td>
            </tr>
        </thead>
        <tbody>
            @foreach (var item in Model)
            {
                var status = item.Status >= Inovout.Kuajing.Models.ShipmentOrderStatus.Shipped ? "已发货" : "未发货";
                <tr>
                    <td><a href='@Url.Action("LoadOrderDetail", "Order", new { orderNo = item.No, is_ship = true })'>@item.No</a>
                        <input type="hidden" value="@item.Id" />
                    </td>
                    <td>@item.ReceiverName</td>
                    <td>@item.ReceiverAddress</td>
                    <td>@item.ReceiverMobile</td>
                    <td>@item.LogisticsCompanyName</td>
                    <td>@status</td>
                    <td>@item.Amount</td>
                    <td>
                        <input type="hidden" value='@item.LogisticsOrderNo' /><a href="#">修改</a></td>
                </tr>
            }
        </tbody>
    </table>
</div>


<div class="modal fade" id="shipper">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">订单</h4>
            </div>
            <div class="modal-body">
                <form  id="orderform" method="post" action='@Url.Action("SaveSingleShippedOrder", "Order")'>
                    <input type="hidden"  name="ConsignerId" id="ConsignerId"  value="@ViewBag.ConsignerId" >
                    <input type="hidden"  name="orderId" id="orderId"  value="@ViewBag.ConsignerId" >
                    <div class="form-group">
                        <label for="logisticsOrderNo">订单号</label>
                        <input type="text" class="form-control" name="orderNo" id="orderNo" readonly="true" placeholder="订单号">
                    </div>
                    <div class="form-group">
                        <label for="logisticsOrderNo">运单号</label>
                        <input type="text" class="form-control" name="logisticsOrderNo" id="logisticsOrderNo" placeholder="运单号">
                    </div>
                    <div class="form-group">
                        <label for="LogisticsCompanyName">物流公司</label>
                        <input type="text" class="form-control" name="logisticsCompanyName" id="logisticsCompanyName" placeholder="运输公司">
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                <button id="save" type="button" class="btn btn-primary">Save</button>
            </div>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal-dialog -->
</div>
<!-- /.modal -->
@section scriptsBody {
    <script>
        

    </script>

}